<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('kh list')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="form">
					<input type="hidden" id="pageFlag" name="pageFlag" th:value="${result.pageFlag}"/>
					<div class="select-list">
						<ul>
							<li class="select-time">
								<label>考评月份： </label>
								<input type="text" class="" id="monthId" name="monthId" th:value="${result.monthId}"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								
								<a style="margin-left:20px;" class="btn btn-danger btn-rounded btn-sm" onclick="calcAll()"
									th:if="${'MANAGE' == result.pageFlag}">
									<i class="fa fa-calc"></i> 全部重新计算
								</a>
								<a style="margin-left:20px;" class="btn btn-warning btn-rounded btn-sm" onclick="doExport()" >
									<i class="fa fa-download"></i> 导出
								</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: datetimepicker-js" />
	<script th:inline="javascript">
		var prefix = ctx + "rate/result";
		var pageFlag = [[${result.pageFlag}]];
		var yesNoDict = [[${@dict.getType('sys_yes_no')}]];

		$(function() {
			$("#monthId").datetimepicker({
				format: 'yyyy-mm',
				weekStart: 1,
				autoclose: true,
				startView: 3,
				minView: 3
			});
			list();
		});

		function list() {
			var cols = [];
			cols.push({
				field: 'id',
				visible: false
			});
			cols.push({
				field: 'dept.deptName',
				align: 'center',
				title: '单<br/>位'
			});
			cols.push({
				field: 'df001qz',
				align: 'center',
				title: '监管改造<br/>权重得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'df002qz',
				align: 'center',
				title: '劳动改造<br/>权重得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'df003qz',
				align: 'center',
				title: '队伍管理<br/>权重得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'df004qz',
				align: 'center',
				title: '综合保障<br/>权重得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'khb',
				align: 'center',
				title: '综合<br/>考核办',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'jcfqz',
				align: 'center',
				title: '基础分<br/>权重',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'totalxckh',
				align: 'center',
				title: '现场考核<br/>得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'xckhqz',
				align: 'center',
				title: '现场考核<br/>权重得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'ldcpfpjz',
				align: 'center',
				title: '领导<br/>测评分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'kscpfpjz',
				align: 'center',
				title: '科室<br/>测评分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'jqcpfpjz',
				align: 'center',
				title: '监区<br/>测评分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'cpfqz',
				align: 'center',
				title: '测评<br/>得分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'zxkh',
				align: 'center',
				title: '专项<br/>考核',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'szpy',
				align: 'center',
				title: '述职<br/>评议',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'supfmqd',
				align: 'center',
				title: '负面<br/>清单'
			});
			cols.push({
				field: 'zdf',
				align: 'center',
				title: '总<br/>分',
				formatter: function(value, row, index) {
					return formatNumber(value);
				}
			});
			cols.push({
				field: 'pm',
				align: 'center',
				title: '排<br/>名'
			});
			/**
			cols.push({
				field: 'khbz',
				align: 'center',
				title: '是否<br/>参与<br/>考核',
				formatter: function(value, row, index) {
					return $.table.selectDictLabel(yesNoDict, value);
				}
			});
			**/
			/**
			cols.push({
				title: '操作',
				align: 'center',
				width: '30%',
				formatter: function(value, row, index) {
					var status = row.status;
					
					var actions = [];
					if ("MANAGE" == pageFlag) {
						actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="calcOne(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新计算</a> ');
					}
					return actions.join('');
				}
			});**/
			
			var options = {
				url: prefix + "/list",
				exportUrl: prefix + "/export",
				modalName: "考核结果",
				columns: cols,
				pagination: false
			};
			$.table.init(options);
		}
		
		function calcAll() {
			$.modal.confirm("重新计算将清空已有数据，请确认是否要重新计算?", function() {
				var url = prefix + "/calcAll";
				var monthId = $("#monthId").val();
				var data = {"timestamp": new Date().getTime(), "monthId": monthId};
				$.operate.submit(url, "post", "json", data);
			});
		}
		
		function doExport() {
			if ($("#monthId").val() == '') {
				$.modal.alertWarning("请选择考核月份！");
				return false;
			}
			$.table.exportExcel();
		}
		
		function formatNumber(input) {
			if (input == null) {
				return "-";
			}
			
			var _input = input.toString();
			
			if (_input == "0") {
				return "-";
			}
			/**
			
			if (_input.indexOf(".") <= 0) {
				return _input;
			}
			**/
			/**
			var digitLength = _input.substr(_input.indexOf(".") + 1).length;
			if (digitLength == 1) {
				return _input + "0";
			}
			**/
			return _input;
		}
	</script>
</body>
</html>